package com.someclip.component.controlls
{
	import com.someclip.component.core.Component;
	import com.someclip.component.interfaces.IIconButton;

	public class IconButton extends BaseButton implements IIconButton
	{
		private var _ico:Component;
		private var _icoStyle:Object;
		private var _icoVisible:Boolean=true;

		public function IconButton()
		{
			this.width=75;
			this.height=20;
			_ico=new Component();
			_ico.width=Math.min(this.height, this.width) * 3 / 5;
			_ico.height=_ico.width;
			_ico.vCenter=0;
			_ico.hCenter=0;
			_ico.visible=_icoVisible;
			addChild(_ico);
			_ico.mouseChildren=false;
			_ico.mouseEnabled=false;
		}

		public function get iconStyle():Object
		{
			return _ico.styleLink;
		}

		public function set iconStyle(value:Object):void
		{
			if (value == _icoStyle)
				return;
			_icoStyle=value;
			if (_ico)
			{
				_ico.styleLink=_icoStyle;
				_ico.width=Math.min(this.height, this.width) * 3 / 5;
				_ico.height=_ico.width;
			}
		}

		override public function set height(value:Number):void
		{
			if (_ico)
			{
				_ico.width=Math.min(this.height, this.width) * 3 / 5;
				_ico.height=_ico.width;
			}
			super.height=value;
		}

		public function get iconVisible():Boolean
		{
			if (_ico)
				return _ico.visible;
			return _icoVisible;
		}

		public function set iconVisible(value:Boolean):void
		{
			_icoVisible=value;
			if (_ico)
				_ico.visible=value;
		}
	}
}
